<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>低代码应用服务平台</title>
</head>
<body>
<div id="errormsg" style="display: none"></div>
</body>
<script th:src="@{/vendor/jquery/jquery.min.js}"></script>
<script  th:inline="javascript">
    (function (window, document, $) {
        'use strict';
        var loc =  location.protocol + '//' + location.host;
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        debugger;
        let employeeNO = [[${employeeNO}]];
        let targetUrl  = [[${targetUrl }]];
        $.ajax({
            url: loc + "/api/login/SSOLoginByEmployeeNO",
            type: 'GET',
            data: {code:employeeNO},
            async: false,
            success: function (result) {
                debugger;
                if (result && result.errcode == 0) {
                    localStorage.setItem('refresh_token', result.refresh_token);
                    localStorage.setItem('expireTime', result.expiration);
                    localStorage.setItem('token', result.access_token);
                    localStorage.setItem('corpId',result.userinfo?result.userinfo.corpId:"main");
                    window.location.href = targetUrl;
                }else{
                    $.errorHandle(result.errmsg);
                }
            }
        })
    })(window, document, jQuery);

</script>
</html>